<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>

<div id="filter">
    <s:form action="list" cssClass="tableFilter">
        <tr>
        <th colspan="4" class="tableTitle">
            <h5>Search</h5>
        </th>
        </tr>
        <tr>
            <td>
                <label>Category:</label>
            </td>
            <td>
                <s:select id="category" list="#{'':'Choose a Category', 'Molecula':'Molecula', 'Master':'Master'}" label="Category" name="category" theme="simple" />
            </td>
        </tr>
        <tr>
            <td>
                <label>Drug:</label>
            </td>
            <td>
                <s:select label="Drug" name="cdaMolecula.droga.id" id="droga"
                          headerKey="" headerValue="Choose a Drug"
                          list="drogaList"
                          listKey="id"
                          listValue="drugName"
                          theme="simple">
                </s:select>
            </td>
        </tr>
        <tr>
            <td>
                <label>Site:</label>
            </td>
            <td>
                <s:select label="Site" name="cdamaster.centro.id" id="site"
                          headerKey="" headerValue="Choose a Site"
                          list="centroList"
                          listKey="id"
                          listValue="institucion"
                          theme="simple">
                </s:select>
            </td>
            <td></td>
            <td></td>
        </tr>

        <tr>
            <td colspan="4" class="centeredButtons"><s:submit value="Search" name="filter" theme="simple" />
                <s:submit action="create" value="New" theme="simple" onclick="resetForms();"/></td>

        </tr>
    </s:form>

</div>

<s:if test="!list.isEmpty()"  >

    <div id="table_content">
        <table class="paginated-table">
            <thead>
            <tr>
                <th>Category</th>
                <th>Drug</th>
                <th>Investigator</th>
                <th>Site</th>
                <th>Expiration</th>
               <th></th>
            </tr>
            </thead>
            <tbody>
            <s:iterator value="list" var="role">
            <tr>
                <th><s:if test="centro != null">Master</s:if><s:else>Molecula</s:else></th>
                <th><s:if test="droga != null"><s:property value="droga.drugName"/></s:if> </th>
                <th><s:if test="involucrado != null"><s:property value="involucrado.apellido"/>, <s:property value="involucrado.nombre"/></s:if> </th>
                <th><s:if test="centro != null"><s:property value="centro.institucion"/></s:if> </th>
                <th><s:date name="expiration" format="dd-MMM-yy" /></th>
                <th>
                    <s:form action="create" method="POST">
                        <s:if test="centro != null">
                            <s:hidden value="Master" name="category"/>
                        </s:if>
                        <s:else>
                            <s:hidden value="Molecula" name="category"/>
                        </s:else>
                        <s:hidden value="%{id}" name="id"/>
                        <a onclick="$(this).closest('form').submit()"><img src="<s:url value="/images/edit.png"/>" title="Edit" alt="Edit"></a></TH>
            </s:form>
                </th>
            </tr>
            </s:iterator>

            <tbody>
        </table>
       <div style="width: 100%;text-align: center" >
            <span class="prev" style="" >Previous</span><span class="next">Next</span>
       </div>

        <script type="text/javascript">
           paginar(10);
        </script>
    </div>
</s:if>

<script type="text/javascript">
    var list = true;
    $('#cda').css({"color":"#EE5102","fontWeight":"bold"});
</script>